<?php
	require('config.php');
?>
<html>
	<head>
		<title>Web Administration Service</title>
	</head>
	<body>
		<table border='0'>
			<tbody>
				<?php
					$i = 0;
					foreach ($services as $service) {
						$flagNotExist = false;
						$result = win32_query_service_status($service['service']);
						if (is_array($result)) {
						} else if (is_numeric($result)) {
							switch ($result) {
								case 0x00000424 :
									$flagNotExist = true;
									break;
								default :
									die('Kesalahan lain-lain!');
							}								
						} else {
							die('Parameter tidak benar!');
						}							
				?>							
				<tr>
					<td><?php echo ++$i; ?>. </td>
					<td><?php echo $service['service'] . ' ~ ' . $service['display']; ?></td>
					<td><?php if ($flagNotExist == true) { ?>Tidak<?php } ?> Terinstall</td>
					<td><button onclick='javascript: serviceToggle(<?php echo $i; ?>, <?php echo (($flagNotExist == true) ? 1 : 0); ?>);'><?php if ($flagNotExist == true) { ?>Install<?php } else { ?>Uninstall<?php } ?></button></td>
				</tr>
				<?php
					}
				?>				
			</tbody>
		</table>
		<script language='javascript'>
			<!--
			function serviceToggle(id, flag) {
				location = 'toggle.php?id=' + id + '&flag=' + flag + '&back=web.php';
			}
			//-->
		</script>
	</body>
</html>